home *** CD-ROM | disk | FTP | other *** search
/ Freelog 121 / FreelogMagazineJuilletAout2014-No121.iso / Outils / Adobe-Air / adobe-air_13.exe / [0] / setup.swf / scripts / mx / skins / halo / ButtonSkin.as < prev    next >
Text File  |  2014-03-27  |  7KB  |  181 lines

  1. package mx.skins.halo
  2. {
  3.    import flash.display.GradientType;
  4.    import mx.core.IButton;
  5.    import mx.core.UIComponent;
  6.    import mx.core.mx_internal;
  7.    import mx.skins.Border;
  8.    import mx.styles.StyleManager;
  9.    import mx.utils.ColorUtil;
  10.    
  11.    use namespace mx_internal;
  12.    
  13.    public class ButtonSkin extends Border
  14.    {
  15.       
  16.       mx_internal static const VERSION:String = "3.0.0.0";
  17.       
  18.       private static var cache:Object = {};
  19.        
  20.       
  21.       public function ButtonSkin()
  22.       {
  23.          super();
  24.       }
  25.       
  26.       private static function calcDerivedStyles(param1:uint, param2:uint, param3:uint) : Object
  27.       {
  28.          var _loc5_:Object = null;
  29.          var _loc4_:String = HaloColors.getCacheKey(param1,param2,param3);
  30.          if(!cache[_loc4_])
  31.          {
  32.             _loc5_ = cache[_loc4_] = {};
  33.             HaloColors.addHaloColors(_loc5_,param1,param2,param3);
  34.          }
  35.          return cache[_loc4_];
  36.       }
  37.       
  38.       override public function get measuredWidth() : Number
  39.       {
  40.          return UIComponent.DEFAULT_MEASURED_MIN_WIDTH;
  41.       }
  42.       
  43.       override public function get measuredHeight() : Number
  44.       {
  45.          return UIComponent.DEFAULT_MEASURED_MIN_HEIGHT;
  46.       }
  47.       
  48.       override protected function updateDisplayList(param1:Number, param2:Number) : void
  49.       {
  50.          var _loc16_:Number = NaN;
  51.          var _loc17_:Array = null;
  52.          var _loc18_:Array = null;
  53.          var _loc19_:Array = null;
  54.          var _loc20_:Array = null;
  55.          var _loc21_:Array = null;
  56.          var _loc22_:Array = null;
  57.          super.updateDisplayList(param1,param2);
  58.          var _loc3_:uint = getStyle("borderColor");
  59.          var _loc4_:Number = getStyle("cornerRadius");
  60.          var _loc5_:Array = getStyle("fillAlphas");
  61.          var _loc6_:Array = getStyle("fillColors");
  62.          StyleManager.getColorNames(_loc6_);
  63.          var _loc7_:Array = getStyle("highlightAlphas");
  64.          var _loc8_:uint = getStyle("themeColor");
  65.          var _loc9_:Object = calcDerivedStyles(_loc8_,_loc6_[0],_loc6_[1]);
  66.          var _loc10_:Number = ColorUtil.adjustBrightness2(_loc3_,-50);
  67.          var _loc11_:Number = ColorUtil.adjustBrightness2(_loc8_,-25);
  68.          var _loc12_:Boolean = false;
  69.          if(parent is IButton)
  70.          {
  71.             _loc12_ = IButton(parent).emphasized;
  72.          }
  73.          var _loc13_:Number = Math.max(0,_loc4_);
  74.          var _loc14_:Number = Math.max(0,_loc4_ - 1);
  75.          var _loc15_:Number = Math.max(0,_loc4_ - 2);
  76.          graphics.clear();
  77.          switch(name)
  78.          {
  79.             case "selectedUpSkin":
  80.             case "selectedOverSkin":
  81.                drawRoundRect(0,0,param1,param2,_loc13_,[_loc8_,_loc11_],1,verticalGradientMatrix(0,0,param1,param2));
  82.                drawRoundRect(1,1,param1 - 2,param2 - 2,_loc14_,[_loc6_[1],_loc6_[1]],1,verticalGradientMatrix(0,0,param1 - 2,param2 - 2));
  83.                break;
  84.             case "upSkin":
  85.                _loc17_ = [_loc6_[0],_loc6_[1]];
  86.                _loc18_ = [_loc5_[0],_loc5_[1]];
  87.                if(_loc12_)
  88.                {
  89.                   drawRoundRect(0,0,param1,param2,_loc13_,[_loc8_,_loc11_],1,verticalGradientMatrix(0,0,param1,param2),GradientType.LINEAR,null,{
  90.                      "x":2,
  91.                      "y":2,
  92.                      "w":param1 - 4,
  93.                      "h":param2 - 4,
  94.                      "r":_loc4_ - 2
  95.                   });
  96.                   drawRoundRect(2,2,param1 - 4,param2 - 4,_loc15_,_loc17_,_loc18_,verticalGradientMatrix(2,2,param1 - 2,param2 - 2));
  97.                   drawRoundRect(2,2,param1 - 4,(param2 - 4) / 2,{
  98.                      "tl":_loc15_,
  99.                      "tr":_loc15_,
  100.                      "bl":0,
  101.                      "br":0
  102.                   },[16777215,16777215],_loc7_,verticalGradientMatrix(1,1,param1 - 2,(param2 - 2) / 2));
  103.                }
  104.                else
  105.                {
  106.                   drawRoundRect(0,0,param1,param2,_loc13_,[_loc3_,_loc10_],1,verticalGradientMatrix(0,0,param1,param2),GradientType.LINEAR,null,{
  107.                      "x":1,
  108.                      "y":1,
  109.                      "w":param1 - 2,
  110.                      "h":param2 - 2,
  111.                      "r":_loc4_ - 1
  112.                   });
  113.                   drawRoundRect(1,1,param1 - 2,param2 - 2,_loc14_,_loc17_,_loc18_,verticalGradientMatrix(1,1,param1 - 2,param2 - 2));
  114.                   drawRoundRect(1,1,param1 - 2,(param2 - 2) / 2,{
  115.                      "tl":_loc14_,
  116.                      "tr":_loc14_,
  117.                      "bl":0,
  118.                      "br":0
  119.                   },[16777215,16777215],_loc7_,verticalGradientMatrix(1,1,param1 - 2,(param2 - 2) / 2));
  120.                }
  121.                break;
  122.             case "overSkin":
  123.                if(_loc6_.length > 2)
  124.                {
  125.                   _loc19_ = [_loc6_[2],_loc6_[3]];
  126.                }
  127.                else
  128.                {
  129.                   _loc19_ = [_loc6_[0],_loc6_[1]];
  130.                }
  131.                if(_loc5_.length > 2)
  132.                {
  133.                   _loc20_ = [_loc5_[2],_loc5_[3]];
  134.                }
  135.                else
  136.                {
  137.                   _loc20_ = [_loc5_[0],_loc5_[1]];
  138.                }
  139.                drawRoundRect(0,0,param1,param2,_loc13_,[_loc8_,_loc11_],1,verticalGradientMatrix(0,0,param1,param2),GradientType.LINEAR,null,{
  140.                   "x":1,
  141.                   "y":1,
  142.                   "w":param1 - 2,
  143.                   "h":param2 - 2,
  144.                   "r":_loc4_ - 1
  145.                });
  146.                drawRoundRect(1,1,param1 - 2,param2 - 2,_loc14_,_loc19_,_loc20_,verticalGradientMatrix(1,1,param1 - 2,param2 - 2));
  147.                drawRoundRect(1,1,param1 - 2,(param2 - 2) / 2,{
  148.                   "tl":_loc14_,
  149.                   "tr":_loc14_,
  150.                   "bl":0,
  151.                   "br":0
  152.                },[16777215,16777215],_loc7_,verticalGradientMatrix(1,1,param1 - 2,(param2 - 2) / 2));
  153.                break;
  154.             case "downSkin":
  155.             case "selectedDownSkin":
  156.                drawRoundRect(0,0,param1,param2,_loc13_,[_loc8_,_loc11_],1,verticalGradientMatrix(0,0,param1,param2));
  157.                drawRoundRect(1,1,param1 - 2,param2 - 2,_loc14_,[_loc9_.fillColorPress1,_loc9_.fillColorPress2],1,verticalGradientMatrix(1,1,param1 - 2,param2 - 2));
  158.                drawRoundRect(2,2,param1 - 4,(param2 - 4) / 2,{
  159.                   "tl":_loc15_,
  160.                   "tr":_loc15_,
  161.                   "bl":0,
  162.                   "br":0
  163.                },[16777215,16777215],_loc7_,verticalGradientMatrix(1,1,param1 - 2,(param2 - 2) / 2));
  164.                break;
  165.             case "disabledSkin":
  166.             case "selectedDisabledSkin":
  167.                _loc21_ = [_loc6_[0],_loc6_[1]];
  168.                _loc22_ = [Math.max(0,_loc5_[0] - 0.15),Math.max(0,_loc5_[1] - 0.15)];
  169.                drawRoundRect(0,0,param1,param2,_loc13_,[_loc3_,_loc10_],0.5,verticalGradientMatrix(0,0,param1,param2),GradientType.LINEAR,null,{
  170.                   "x":1,
  171.                   "y":1,
  172.                   "w":param1 - 2,
  173.                   "h":param2 - 2,
  174.                   "r":_loc4_ - 1
  175.                });
  176.                drawRoundRect(1,1,param1 - 2,param2 - 2,_loc14_,_loc21_,_loc22_,verticalGradientMatrix(1,1,param1 - 2,param2 - 2));
  177.          }
  178.       }
  179.    }
  180. }
  181.